﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            Faculty faculty = Faculty.GenerateRandonFaculty();
                      
                faculty.PrintFacultyToConsole();
            Console.ReadLine();
        }
    }


    class Faculty
    {
        public string Name;
        public List<Chair> chairs = new List<Chair>();

        public static int facultyCount;

        public static Faculty GenerateRandonFaculty()
        {
            Faculty faculty = new Faculty();
            faculty.Name = "Faculty" + facultyCount++;
            for (int i = 0; i < 3; i++)
            {
                Chair chairOne = Chair.GenerateRandomChair();
                faculty.chairs.Add(chairOne);
            }
            return faculty;
        }

        //    public void GenerateRandomFacultyOne()
        //{
        //    Faculty faculty = new Faculty();
        //    faculty.Name = "Faculty" + facultyCount++;
        //    for (int i = 0; i < 3; i++)
        //    {
        //        int 
        //    }
        //}

        public void PrintFacultyToConsole()
        {
            Console.WriteLine("Facullty Name {0}", Name);
            foreach (var chair in chairs)
            {
                chair.PrintChairToConsole();
            }
        }
    }
    



    class Chair
    {
        public string Name;
        public List<Group> groups = new List<Group>();

        public static int chairCount = 100;

        public static Chair GenerateRandomChair()
        {
            Chair chair = new Chair();
            chair.Name = "Chair" + chairCount++;
            for (int i = 0; i < 3; i++)
            {
                Group grp = Group.GenerateRandomGroup();
                chair.groups.Add(grp);
            }
            return chair;
        }

        public void PrintChairToConsole()
        {
            Console.WriteLine("++++++++++++++++++++++");
            Console.WriteLine("Chair Name: {0}", Name);
            Console.WriteLine("++++++++++++++++++++++");
            foreach (var group in groups)
            {
                group.PrintGroupToConsole();
            }
        }
    }


    class Group
    {
        public string Name;
        public List<Student> students = new List<Student>();

        public static int groupCount;

        public static Group GenerateRandomGroup()
        {
            groupCount++;
            Group group = new Group();
            group.Name = "Group" + Group.groupCount;
            for (int i = 0; i < 5; i++)
            {
                Student student = Student.GenerateRandomStudent();
                group.students.Add(student);
            }
            return group;
        }

        public void PrintGroupToConsole()
        {
            Console.WriteLine("***************");
            Console.WriteLine("Group: {0}", Name);
            Console.WriteLine("***************");
            foreach (var student in students)
            {
                //student.CalculateAvgMark();
                //if (student.Marks.Average > 80)
                
                    student.PrintStudentInfoToConsole();
                    Console.WriteLine("--------------");
                            
            }
            Console.WriteLine("================");
        }
    }


        class Student
    {
        public string FirstName;
        public string LastName;
        public DateTime DateOfBirth;
        public List<int> Marks = new List<int>();

        public static Random rndGenerator = new Random();
        public static int StudentCount;

        public void GenerateRandomStudentParameters()
        {
            StudentCount++;
            FirstName = "Вася";
            LastName = Student.StudentCount.ToString();
            DateOfBirth = new DateTime(Student.rndGenerator.Next(1990, 2012), Student.rndGenerator.Next(1, 13), Student.rndGenerator.Next(1, 21));
            for (int i = 0; i < 5; i++)
            {
                int mark = Student.rndGenerator.Next(1, 101);
                Marks.Add(mark);
            }
        }

        public static Student GenerateRandomStudent()
        {
            Student.StudentCount++;
            Student student = new Student();
            student.FirstName = "Вася";
            student.LastName = Student.StudentCount.ToString();
            student.DateOfBirth = new DateTime(Student.rndGenerator.Next(1990, 2012), Student.rndGenerator.Next(1, 13), Student.rndGenerator.Next(1, 21));
            for (int i = 0; i < 5; i++)
            {
                int mark = Student.rndGenerator.Next(1, 101);
                student.Marks.Add(mark);
            }
            return student;
        }

        public void PrintStudentMarksToConsole()
        {          
            foreach (var mark in Marks)
              
            {           
                Console.WriteLine(mark);
            }
        }

        public void PrintStudentInfoToConsole()
        {
            Console.WriteLine("First Name: {0}", FirstName);
            Console.WriteLine("Last Name: {0}", LastName);
            Console.WriteLine("Birthday: {0}", DateOfBirth.ToString("dd/MM/yyyy"));
        }

        public double CalculateAvgMark()
        {
            return Marks.Average();
        }


    }
}



